﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class RolesControllerBase : Controller{
	public RolesControllerBase()
		: base()
	{
	}
	private static RolesDAO _Service; 
	public static RolesDAO Service{
		get{
			if(_Service==null)
				_Service = new RolesDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public RolesEntity MapDataRowToObject(DataRow row){
		RolesEntity o = new RolesEntity();
		 o.RoleName=Convert.ToString(row["RoleName"]);
		 o.Note=Convert.ToString(row["Note"]);
		 if(!row.IsNull("RoleType"))
			o.RoleType=ConvertByte(row["RoleType"]);
		 if(!row.IsNull("RoleId"))
		    o.RoleId=(Int32)(row["RoleId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(RolesEntity o,DataRow row){
		row["RoleName"]=o.RoleName;
		row["Note"]=o.Note;
		row["RoleType"]=o.RoleType;
		row["RoleId"]=o.RoleId;
    }
}
}
